# Maintainer: Christian Rebischke <chris.rebischke@archlinux.org>

pkgname=kubeconform
pkgver=0.6.3
pkgrel=1
pkgdesc="FAST Kubernetes manifests validator, with support for Custom Resources!"
url="https://github.com/yannh/kubeconform"
arch=("loong64" "x86_64")
license=("Apache")
depends=('glibc')
makedepends=("go" "git")
source=("${pkgname}-${pkgver}::https://github.com/yannh/kubeconform/archive/refs/tags/v${pkgver}.tar.gz")
sha512sums=('976bb601a4f922a33e0c6cb630c78856b2ae814e0162e65ba358d1982bb2c68d8a1bef92eb90dccf05ae8ad70890039313791032e111c1f984d01a5d2380261a')
b2sums=('3b856ecbf3ccc7d4966fcd60a411945be8864b2eacb752e08960bdf9bdafc0933ec0f69b1d4d132186a296d56f61d6fe91db20e8c533090bfddaf3b580ae6128')
options=('!lto')

build() {
  cd "${pkgname}-${pkgver}/cmd/kubeconform"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
  go build -ldflags="-w -s -linkmode=external" .
}

check() {
  cd "${pkgname}-${pkgver}"
  go test ./...
}

package() {
  cd "${pkgname}-${pkgver}"
  install -Dm755 "cmd/kubeconform/kubeconform" "${pkgdir}/usr/bin/${pkgname}"
}
